//导入jwt
const jwt = require('jsonwebtoken');
//创建token
//let token = jwt.sign(用户数据对象,加密字符串,配置对象是生命周期，单位是秒,如小时是60*60)
// let token = jwt.sign({username:'zhangsan'},'atguigu',{expiresIn:60*2})
// console.log(token);
//把生成的token赋值给t，进行校验
let t = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InpoYW5nc2FuIiwiaWF0IjoxNzUwMTU4NTc1LCJleHAiOjE3NTAxNTg2OTV9.kFyscPNXngfslRwf2DT0YZ9rVsm8JHKf8coh_ioK9p0';
//jwt.verify(被验证的token,加密字符串,回调函数)
jwt.verify(t,'atguigu',(err,data)=>{
    if(err){
        console.log('校验失败~~');
        return
    }
    console.log(data);
})